package com.sunxu.spring.scope;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 孙许
 * @date 2018-07-14
 * @description 第一次没有messageServiceImpl 则创建，放入ThreadLocal中，
 * 第二次直接从ThreadLocal中取出
 */
public class Application {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        MessagePrinter printer = context.getBean(MessagePrinter.class);
        printer.printMessage();

        MessagePrinter printer2 = context.getBean(MessagePrinter.class);
        printer2.printMessage();
    }
}
